Back to course home
0% completed
Vote For New Content
Concurrency Control
Understanding the Concurrency Control
Optimistic vs. Pessimistic Concurrency Control
Lock-Based Concurrency Control
Timestamp-Based Concurrency Control
Multiversion Concurrency Control (MVCC)
Quiz
Distributed Databases, Data Partitioning & Sharding
Fundamentals of Distributed Databases
Partitioning in Databases
Partitioning Types
Sharding in Databases
Distributed Query Processing
Quiz
Data Replication and Consistency Models
Replication in Databases
Replication Topologies
Understanding the Consistency Models in Databases
The CAP Theorem and Its Implications
Quiz
Consenus and Leader Election
Understanding the Consensus
Consensus algorithms
Leader Election Strategies
Quiz
Recovery and Fault Tolerance in Distributed Databases
Understanding the Fault Tolerance
Logging Mechanisms in Databases
Checkpointing and Recovery Basics
Coordinated Recovery in Distributed Systems
High Availability Through Replication and Failover
Ensuring Data Resilience: Redundancy, Mirroring, and Recovery
Quiz
NoSQL Databases and New Data Models
Introduction to NoSQL
Key-Value Stores
Document-Oriented Databases
Column-Family and Wide-Column Stores
Graph Databases
Quiz
Advanced Topics and Emerging Trends
In-Memory Databases
NewSQL Databases
Time-Series and Spatial Databases
Big Data and Distributed Processing Frameworks
Quiz
Database Design Case Studies
Quora System Design & Database Design
TikTok System Design & Database Design
Airbnb System Design & Database Design
Snapchat System Design & Database Design
Durability
What is Durability?
Durability, one of the ACID properties, ensures that once a transaction is successfully committed, its changes are permanently stored in the database. Even in the event of system crashes, power failures, or hardware malfunctions, the database guarantees that committed data is not lost.
Once saved, your data is safe and will not be lost after failures.
Importance of Durability
-
Data Reliability:
- Applications depend on durability to ensure that important information is not lost after a transaction is completed.
- Example: A bank transaction deducting $100 from an account must remain recorded even if the system crashes immediately afterward.
-
Fault Tolerance:
- Durability ensures that a database can recover to a consistent state after failures, with all committed transactions intact.
-
User Trust:
- Durability builds user trust by providing confidence that their data is safe and persistent.
How Durability is Achieved
Modern databases use a combination of techniques to ensure durability:
1. Write-Ahead Logging (WAL)
- Before applying changes to the database, a log of the changes is written to a persistent storage medium (like a disk).
- In case of a failure, the log is replayed to recover the committed transactions.
Example:
- Transaction T1 commits, and its changes are logged.
- System crashes before changes are written to the database.
- On recovery, the log is replayed to reapply T1's changes, ensuring durability.
2. Checkpointing
- Periodically, the database takes a "snapshot" of its current state and saves it to disk.
- Checkpoints reduce recovery time by limiting the number of logs that need to be replayed during recovery.
3. Synchronous Disk Writes
- Changes are written to disk immediately upon committing a transaction.
- Ensures that the database doesn't rely on volatile memory (e.g., RAM) to store committed data.
4. Replication
- Changes are replicated to multiple nodes or servers to ensure data redundancy.
- Even if one node fails, other nodes maintain a consistent copy of the data.
Example:
- A distributed database like MongoDB replicates changes across its replica set.
- A failure in the primary node doesn’t affect data availability because replicas retain the committed data.
Examples of Durability in Action
Scenario 1: Bank Transaction
- User transfers $1,000 from Account A to Account B.
- Transaction commits, and the changes are written to the transaction log.
- A power failure occurs immediately after the commit.
- On recovery, the database uses the log to ensure that the $1,000 transfer is preserved.
Scenario 2: E-commerce Order
- A user places an order for a product.
- The transaction commits, and the database saves the order details and payment information.
- A system crash occurs right after the commit.
- The user’s order is still recorded because the database ensures durability.
Isolation
Quiz
Mark as Completed
On this page
What is Durability?
Importance of Durability
How Durability is Achieved
- Write-Ahead Logging (WAL)
- Checkpointing
- Synchronous Disk Writes
- Replication
Examples of Durability in Action
Scenario 1: Bank Transaction
Scenario 2: E-commerce Order